fix(pm): bin link - #2458
Conversation
elrrrrrrr
commented
Dec 26, 2025
- 🤖 fix empty bin [Utoo PM] 依赖如果有空 bin 会安装失败 #2456
Summary of ChangesHello @elrrrrrrr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where package managers might incorrectly process empty binary paths defined in package metadata. By introducing robust filtering mechanisms, the system now gracefully handles malformed or incomplete 'bin' configurations, ensuring that only valid executable paths are considered. This improves the reliability and stability of package parsing and linking processes. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with empty bin entries in package.json not being filtered out. The changes are applied consistently across pm, ruborist/model/package_json, and ruborist/model/package_lock to ensure empty binary paths are ignored. The logic is sound, and the inclusion of new tests to verify the fix is a great addition. I have a couple of suggestions to improve the efficiency of the implementation in package.rs and package_json.rs by avoiding intermediate collections.
| pub fn entries(&self, package_name: &str) -> Vec<(String, String)> { | ||
| match self { | ||
| let entries: Vec<_> = match self { | ||
| BinConfig::Single(path) => vec![(package_name.to_string(), path.clone())], | ||
| BinConfig::Map(map) => map.iter().map(|(k, v)| (k.clone(), v.clone())).collect(), | ||
| } | ||
| }; | ||
| entries.into_iter().filter(|(_, p)| !p.is_empty()).collect() | ||
| } |
There was a problem hiding this comment.
While this implementation is correct, it can be made more efficient. Creating an intermediate Vec and then iterating over it again to filter can be avoided. You can perform the filtering directly within the match arms for a cleaner and more performant solution.
pub fn entries(&self, package_name: &str) -> Vec<(String, String)> {
match self {
BinConfig::Single(path) => {
if !path.is_empty() {
vec![(package_name.to_string(), path.clone())]
} else {
vec![]
}
}
BinConfig::Map(map) => map
.iter()
.filter(|(_, v)| !v.is_empty())
.map(|(k, v)| (k.clone(), v.clone()))
.collect(),
}
}There was a problem hiding this comment.
Pull request overview
This PR fixes issue #2456 by filtering out empty bin paths across the codebase. The implementation ensures that empty string values in the bin field of package.json and package-lock.json files are properly filtered out to prevent linking errors.
- Adds filtering logic to remove empty bin paths in three modules
- Includes comprehensive test coverage for the new filtering behavior in two of the three modified files
- Updates documentation comments to clarify that empty bin paths are filtered out
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/ruborist/src/model/package_lock.rs | Adds filtering for empty bin paths in parse_bin_files() method with guard clause for string case and filter for object case; includes comprehensive tests |
| crates/ruborist/src/model/package_json.rs | Adds filtering for empty bin paths in BinConfig::entries() method using a unified filter approach; includes comprehensive tests |
| crates/pm/src/model/package.rs | Refactors bin parsing logic to filter empty bin paths; lacks test coverage for the new filtering behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.